package cn.com.gaobb.controller;

import cn.com.gaobb.dto.ResultDTO;
import cn.com.gaobb.service.GoodsService;
import cn.com.gaobb.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author haopt
 * @version 1.0
 * @ClassName GoodsController
 * @Description TODO
 * @date 2021/4/2 10:33
 */
@RestController
@RequestMapping("/api/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @PostMapping("/add")
    public ResultDTO<ResIdVO> add(@RequestBody ReqGoodsAddVO reqVO) {
        return goodsService.add(reqVO);
    }

    @PostMapping("/update")
    public ResultDTO update(@RequestBody ReqGoodsUpdateVO vo) {
        return goodsService.update(vo);
    }

    @PostMapping("/deleteList")
    public ResultDTO deleteList(@RequestBody ReqGoodsDeleteListVO vo) {
        return goodsService.deleteList(vo);
    }

    @GetMapping("/detail")
    public ResultDTO<ResGoodsDetailVO> detail(@RequestParam("id")String id) {
        return goodsService.detail(id);
    }

    @PostMapping("/listOfPage")
    public ResultDTO<ResPageVO<ResGoodsDetailVO>> listOfPage(@RequestBody ReqPageVO vo) {
        return goodsService.listOfPage(vo);
    }

    @GetMapping("/list")
    public ResultDTO<List<ResGoodsDetailVO>> list() {
        return goodsService.list();
    }
}
